import React from 'react';
import './header.scss';
import { hashHistory } from 'react-router';

const headerTitle = {
    'flowSummary': {
        title: '总客流分析',
    },
    'brand': {
        title: '品牌分析',
    },
    'retailPatterns': {
        title: '业态分析'
    },
    'floors': {
        title: '楼层分析'
    },
    'shopList': {
        title: '商场列表',
        rightText: '退出',
        hideBack: true
    },
    'floorsflowSummary': {
        title: '楼层客流分析',
    },
    'retailPatternflowSummary': {
        title: '业态客流分析',
    }
};

import $ from 'jquery';
const Header = React.createClass({
    back() {
        let header = headerTitle[this.props.pathName] || {}
        if (header.hideBack !== true) {
            hashHistory.goBack();
        }
    },
    render() {
        let header = headerTitle[this.props.pathName] || {}, backNode;
        if (header.hideBack !== true) {
            backNode = <i className="icon-back"></i>
        }
        return (
            <header className="flex">
                <div className="flex-col-2 flex-center" onClick={this.back}>
                    {backNode}
                </div>
                <h1 className="flex-g-1">{header.title}</h1>
                <div className="flex-col-2 flex-center">
                    {header.rightText}
                </div>
            </header>
        );
    }
})

module.exports = Header;
